package com.kfm.hotel.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kfm.hotel.mapper.RoomMapper;
import com.kfm.hotel.pojo.Room;
import com.kfm.hotel.pojo.RoomDTO;
import com.kfm.hotel.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomServiceImpl implements RoomService {

    @Autowired
    private RoomMapper roomMapper;

    @Override
    public PageInfo<RoomDTO> listWithRoomType(Integer pageNumber, Integer pageSize, Room room) {
        PageHelper.startPage(pageNumber, pageSize);
        List<RoomDTO> rooms = roomMapper.selectWithRoomType();
        return new PageInfo<>(rooms);
    }

    @Override
    public int saveRoom(Room room) {
        return roomMapper.insertRoom(room);
    }
}
